<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>登陆系统</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<style type="text/css">
body {
	
	background-image: url("img/bgi-login.png");
}

.navbar {
	width: 650px;
	margin-top: 100px;
	margin-left: auto;
	margin-right: auto;
	border-radius:3px 3px 0 0 ;
}

.well {
	width: 479px;
	padding-top:50px;
	padding-bottom: 50px;
	padding-left: 150px;
	margin-left: auto;
	margin-right: auto;
	margin-top: -20px;
	border: 1px solid black;
	border-radius:0 0 3px 3px;
}
</style>
</head>
<body>
	<div class="navbar ">
		<div class="navbar-inner ">
			<div class="container ">
				<a class="brand" href="#" style="font-weight:bold">PMS登陆系统</a>
				<div class="nav-collapse"></div>
			</div>
		</div>
	</div>

	<form class="well" action="" method="post">
		<div class="alert alert-error " style="display:none;width:250px">
			<a class="close" href="#">×</a> <strong></strong>
		</div>
		
		<label>用户名</label> 
		<input type="text" placeholder="请输入用户名" class="span4 name" name="name" /> <span class="help-block"></span> 
		<label>密码</label>
		<input type="password" placeholder="请输入密码" class="span4 pwd" name="password" /> <span class="help-block"></span> 
		<br /> <a class="btn btn-primary">登入系统</a><span id="loading"style="margin-left:20px"><img src="img/loading.gif"/></span>
	</form>

	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#loading").css("display","none");
			$(".close").click(function() {
				$(".alert-error").fadeOut(500);
			});
		
			$(".btn").click(function() {
				var name = $(".name").val();
				var pwd = $(".pwd").val();
				if (name.trim() == "" || pwd.trim() == "") {
					$(".alert-error").css("display", "block");
					$("strong").text("用户名或者密码不能为空");
				} else {
					$.ajax({
							url : "index.jspx",
							type : "POST",
							data : {
								m:"login",
								name : name,
								passwrod : pwd
							},
							beforeSend:function(){
								$("#loading").css("display","inline");
							}
						}).done(function(msg) {
							if(msg == 10002) {
								$(".alert-error").css("display", "block");
								$("strong").text("用户名或者密码错误");
								$("#loading").css("display","none");
							} else if(msg == 10001) {
								$(".alert-error").css("display", "block");
								$("strong").text("用户名或者密码不能为空");
							} else {
								window.location = msg;
							}
						});
				}
			});

		});
	</script>
</body>
</html>
